package com.yunjian.core.basic.model;

import java.io.Serializable;
import java.util.Date;

import com.yunjian.util.ArrayUtil;

public class UserFile implements Serializable {

	/**
	 * user_file.ID 文件编号
	 * @mbggenerated
	 */
	private String id;
	/**
	 * user_file.FILE_ORIGN_NAME 文件原始名称
	 * @mbggenerated
	 */
	private String fileOrignName;
	/**
	 * user_file.FILE_SIZE 文件大小
	 * @mbggenerated
	 */
	private Long fileSize;
	/**
	 * user_file.FILE_EXT 文件后缀
	 * @mbggenerated
	 */
	private String fileExt;
	/**
	 * user_file.SYS_SAVE_PATH 系统存储路径（类似 /系统用户/项目名/）
	 * @mbggenerated
	 */
	private String sysSavePath;
	/**
	 * user_file.BUSI_SAVE_PATH 业务存储路径（/create_user_id/busi_type/file_ext/id）
	 * @mbggenerated
	 */
	private String busiSavePath;
	/**
	 * user_file.BUSI_TYPE 业务类型（用于标注文件用途）
	 * @mbggenerated
	 */
	private String busiType;
	/**
	 * user_file.CREATE_USER_ID 创建人
	 * @mbggenerated
	 */
	private String createUserId;
	/**
	 * user_file.CREATE_TIME 创建时间
	 * @mbggenerated
	 */
	private Date createTime;
	/**
	 * user_file.FILE_STATUS 文件状态（0失效（文件已删除）1正常2待使用3待删除）
	 * @mbggenerated
	 */
	private Integer fileStatus;
	/**
	 * user_file.SYS_NO 系统编号
	 * @mbggenerated
	 */
	private String sysNo;
	/**
	 * @mbggenerated
	 */
	private static final long serialVersionUID = 1L;

	/**
	 * @mbggenerated
	 */
	public String getId() {
		return id;
	}

	/**
	 * @mbggenerated
	 */
	public void setId(String id) {
		this.id = id == null ? null : id.trim();
	}

	/**
	 * @mbggenerated
	 */
	public String getFileOrignName() {
		return fileOrignName;
	}

	/**
	 * @mbggenerated
	 */
	public void setFileOrignName(String fileOrignName) {
		this.fileOrignName = fileOrignName == null ? null : fileOrignName
				.trim();
	}

	/**
	 * @mbggenerated
	 */
	public Long getFileSize() {
		return fileSize;
	}

	/**
	 * @mbggenerated
	 */
	public void setFileSize(Long fileSize) {
		this.fileSize = fileSize;
	}

	/**
	 * @mbggenerated
	 */
	public String getFileExt() {
		return fileExt;
	}

	/**
	 * @mbggenerated
	 */
	public void setFileExt(String fileExt) {
		this.fileExt = fileExt == null ? null : fileExt.trim();
	}

	/**
	 * @mbggenerated
	 */
	public String getSysSavePath() {
		return sysSavePath;
	}

	/**
	 * @mbggenerated
	 */
	public void setSysSavePath(String sysSavePath) {
		this.sysSavePath = sysSavePath == null ? null : sysSavePath.trim();
	}

	/**
	 * @mbggenerated
	 */
	public String getBusiSavePath() {
		return busiSavePath;
	}

	/**
	 * @mbggenerated
	 */
	public void setBusiSavePath(String busiSavePath) {
		this.busiSavePath = busiSavePath == null ? null : busiSavePath.trim();
	}

	/**
	 * @mbggenerated
	 */
	public String getBusiType() {
		return busiType;
	}

	/**
	 * @mbggenerated
	 */
	public void setBusiType(String busiType) {
		this.busiType = busiType == null ? null : busiType.trim();
	}

	/**
	 * @mbggenerated
	 */
	public String getCreateUserId() {
		return createUserId;
	}

	/**
	 * @mbggenerated
	 */
	public void setCreateUserId(String createUserId) {
		this.createUserId = createUserId == null ? null : createUserId.trim();
	}

	/**
	 * @mbggenerated
	 */
	public Date getCreateTime() {
		return createTime;
	}

	/**
	 * @mbggenerated
	 */
	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	/**
	 * @mbggenerated
	 */
	public Integer getFileStatus() {
		return fileStatus;
	}

	/**
	 * @mbggenerated
	 */
	public void setFileStatus(Integer fileStatus) {
		this.fileStatus = fileStatus;
	}

	/**
	 * @mbggenerated
	 */
	public String getSysNo() {
		return sysNo;
	}

	/**
	 * @mbggenerated
	 */
	public void setSysNo(String sysNo) {
		this.sysNo = sysNo == null ? null : sysNo.trim();
	}
	
	/**
	 * 业务类型
	 * @author sonta
	 *
	 */
	public static enum BusiType {
		ROOM_PHOTO("S_0001", new String[]{"jpg", "png"}, 1024 * 1024 * 2, "房源房间图片", "后台系统");
		private String code;
		private String[] allowExts;
		private long allowSize;
		private String descr;
		private String belong;
		private BusiType (String code, String[] allowExts, long allowSize, String desc, String belong) {
			this.setCode(code);
			this.setDescr(desc);
			this.setBelong(belong);
			this.setAllowExts(allowExts);
			this.setAllowSize(allowSize);
		}
		
		public String getCode() {
			return code;
		}
		public void setCode(String code) {
			this.code = code;
		}
		public String getDescr() {
			return descr;
		}
		public void setDescr(String descr) {
			this.descr = descr;
		}
		public String getBelong() {
			return belong;
		}
		public void setBelong(String belong) {
			this.belong = belong;
		}
		
		public String[] getAllowExts() {
			return allowExts;
		}

		public void setAllowExts(String[] allowExts) {
			this.allowExts = allowExts;
		}

		public long getAllowSize() {
			return allowSize;
		}

		public void setAllowSize(long allowSize) {
			this.allowSize = allowSize;
		}
		
		/**
		 * 根据业务代码获取业务类型对象
		 * @param code
		 * @return
		 */
		public static BusiType getTypeByCode(String code) {
			for(BusiType bt : BusiType.values()) {
				if (bt.getCode().equals(code)) {
					return bt;
				}
			}
			return null;
		}
		
		public static  String getBusiTypeStr() {
			StringBuffer sb = new StringBuffer();
			sb.append("[").append("\n");
			int i = 0;
			for (BusiType bt : BusiType.values()) {
				if (i != 0) {
					sb.append(",\n");
				}
				sb.append("{code : ").append(bt.getCode())
				.append(", descr : ").append(bt.getDescr())
				.append(", allowExts : ").append(ArrayUtil.join(bt.getAllowExts(), ","))
				.append(", allowSize : ").append(bt.getAllowSize())
				.append("}");
				i++;
			}
			sb.append("\n").append("]");
			return sb.toString();
		}
	}
}